package kr.or.kiso.database;

import java.io.Reader;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SqlMapConfig {
	
	  private static final SqlMapClient sqlMap;
	  private static String resource = "kr/or/kiso/resources/config/SqlMapConfig.xml";

	  public SqlMapConfig() {
	  }

	  public SqlMapConfig(String resource) {
	    //this.resource = resource;
	  }

	  static {
	    try {
	      Reader reader = Resources.getResourceAsReader (resource);
	      sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
	    } catch (Exception e) {
	      e.printStackTrace();
	      throw new RuntimeException ("Error initializing SqlConfig class. Cause: " + e);
	    }
	  }

	  public static SqlMapClient getSqlMapInstance() {
	    return sqlMap;
	  }
	  
}
